Repository navigation
feat: typed callbacks and errors - #17
Merged
Merged
Conversation
Orchestrator 2.2 reports a failed callback's error as an object: a stable code to branch on and a message to show. CloudEvent::failure() returns it as a Failure, accepting the bare-string code a 2.1 orchestrator still sends mid-upgrade. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
An explicit null error or a non-string message is malformed, not a success; both now raise ClientException. Tests assert the null result and the exception type rather than its prose. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Rector's AssertEmptyNullableObjectToAssertInstanceofRector rewrote assertNull on a ?Failure into assertNotInstanceOf, which hides the contract the test is for. Skip that rule. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
CloudEvent is transport; what a callback's data means is the payload's business. Failure::fromData($event->data) replaces CloudEvent::failure(), and Failure's tests move to their own file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
CloudEvent<T> is an envelope that decodes its data through a callable it is handed, so it never learns what a callback means. The meaning lives in Payload: one readonly DTO per event type, each carrying a Failure where the orchestrator can report one, dispatched by CallbackEvent::decode(). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Orchestrator v2.2.0 reports a failed callback's
erroras{code, message}. This PR gives callbacks a typed surface end to end.CloudEvent<T>is generic and knows nothing about its payload.CloudEvent::decode($payload, $decode)hands the event type and raw data to a callable and stores whatever comes back;fromArray()isdecode()with the identity, so existing raw-array callers are unchanged.One
Callbackper event type, dispatched byCallbackEvent::decode(array $data):orchestrator.job.startJobStartorchestrator.job.logJobLogorchestrator.job.artifactJobArtifact—format/compressionnull when never sniffed,?Error $errororchestrator.job.exitJobExit—exitCode,?reason,?Error $errororchestrator.job.completeJobCompleteorchestrator.deployment.responseDeploymentResponse—?statusCode/?bodynull when the request never reached a replica,?Error $errorCallback\Error(ErrorCode $code,string $message) withEnum\ErrorCodecovering every artifact, exit, and deployment-response code. Strict: a non-objecterror, unknown code, or missing message throwsClientException. No tolerance for the pre-2.2 string shape — pin the SDK to the orchestrator it talks to.Also adds
Data::boolfor the response callback's truncation flags.Test plan
composer test— each event type decodes to its callback; artifact/exit/response error cases; unknown event type and missing fields rejected;Errorobject, null-on-success, and malformed shapescomposer analyze,composer format:check,composer refactor:check🤖 Generated with Claude Code